//
//  SEGAdvlistManager.m
//  Commom
//
//  Created by 山刘 on 2019/4/2.
//  Copyright © 2019年 山刘. All rights reserved.
//

#import "SEGCheckShareRecordManager.h"
#if __has_include(<Commom/SEGModel.h>)
#import <Commom/SEGModel.h>
#else
#import "SEGModel.h"
#endif

#if __has_include(<Commom/SEGHTTPBusinessManager.h>)
#import <Commom/SEGHTTPBusinessManager.h>
#else
#import "SEGHTTPBusinessManager.h"
#endif


static id _checkShareRecordManager;
static dispatch_once_t onceToken;

@implementation SEGCheckShareRecordManager
+(instancetype)sharedManager{
    dispatch_once(&onceToken, ^{
        _checkShareRecordManager = [[self alloc] init];
    });
    return _checkShareRecordManager;
}

+(void)destroyResource{
    onceToken = 0;
    _checkShareRecordManager = nil;
}

/// 请求检测注册用户是否获取分享礼物接口
-(void)requestCheckShareRecordCompleted:(void(^)(BOOL isSuccessed,id result,NSString* codeType,NSString* errorMessage))completed;
{
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/uhomecp-app/share-api/v1/checkShareRecord.json",nil];
    
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:nil completed:^(BOOL isSuccessed, id result, NSString *codeType, NSError *error) {
        if (!isSuccessed) {
            completed(NO,result, @"", kNetworkErrorMessage); //数据返回异常
            return;
        }
        NSDictionary* data = [result valueForKey:@"data"];
        if (data && [data isKindOfClass:[NSDictionary class]]) {
            self.redwalletModel = [SEGInviteRedWalletModel yy_modelWithDictionary:data];
        }
        completed(YES,result, codeType, error.localizedDescription);
    }];
}

-(SEGInviteRedWalletModel *)redwalletModel{
    if (!_redwalletModel) {
        _redwalletModel = [[SEGInviteRedWalletModel alloc]init];
    }
    return _redwalletModel;
}
@end
